package org.example.controller;

import org.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
// <bean id = "userController" class = "org.example.controller.UserController">
// 控制层的组件,是由spring管理的.作为spring的bean存在
// 实际上@Controller和User类的注解@Component起到的作用一模一样,但是为了可读性更强,分开写
public class UserController {
    // @Resources 根据 bean 名字进行自动装配 jdk8 可以直接使用,但是jdk11将其拿到javaee中了
    @Autowired // 根据类型自动装配
    UserService userService;

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }
}
